package com.itheima.health.dao;

import com.itheima.health.pojo.Member;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.OrderSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;

/**
 * 预约数据层
 *
 * @author snowsee
 * @date 2023/4/27 11:58
 */
@Mapper
public interface AppointmentOrderDao {
    /**
     * 根据电话号查询会员信息
     * @param phoneNumber
     * @return
     */
    Member selectByPhoneNumber(@Param("phoneNumber") String phoneNumber);

    /**
     * 创建会员
     * @param member
     */
    void insertMember(Member member);

    /**
     * 查询预约设置
     * @param orderDate
     * @return
     */
    OrderSetting selectOrderSettingByOrderDate(@Param("orderDate") String orderDate);

    /**
     * 预约人数+1
     */
    void updateOrderSetting(@Param("orderDate") Date orderDate);

    /**
     * 存入预约信息 返回主键
     */
    void insertOrder(Order order);

    /**
     * 更新会员
     * @param member
     */
    void updateMember(Member member);

    /**
     * 查询是否有重复预约
     * @param memberId
     * @param orderDate
     * @param setmealId
     * @return
     */
    long countByMemberAndDateAndSetMeal(@Param("memberId") Integer memberId, @Param("orderDate") Date orderDate, @Param("setmealId") Integer setmealId);
}
